<template>
    <div id="have-filed" class="w-h-100 pos-r flex-1 apply-container page-public-s" style="box-sizing: border-box;overflow:hidden;">
        <div class="w-h-100 ver-flex pos-a" style="box-sizing: border-box; padding: 6px;">
            <div style="box-sizing: border-box;">
                <el-card shadow="never" :body-style="{ paddingBottom: '0' }">
                    <el-form class="box-f" ref="queryForm" :inline="true">
                        <el-form-item >
                            <el-button v-if="$hasPer('HaveFiled:excel')" @click="handleExport" icon="ele-Download"> 导出数据 </el-button>
                            <!-- <el-button  @click="stateClick(0,getData)" class="icon-e" text>待整改记录数量<span style="color: #409EFF;margin-left: 5px;">{{ state.n_ToBeRectificationRecordCount }}</span></el-button>
                            <el-button  @click="stateClick(1,getData)" class="icon-e" text>待复查记录数量<span style="color: #67C23A;margin-left: 5px;">{{ state.n_ToBeReviewRecordCount }}</span></el-button>
                            <el-button  @click="stateClick(2,getData)" class="icon-e" text>待验收记录数量<span style="color: #865205;margin-left: 5px;">{{ state.n_ToBeAcceptanceRecordCount }}</span></el-button> -->
                            <el-button class="icon-e" text>已归档记录数量<span style="color: #E6A23C;margin-left: 5px;">{{ state.n_FinishedRecordCount }}</span></el-button>
                            <!-- <el-button  @click="stateClick(4,getData)" class="icon-e" text>复查不通过记录数量<span style="color: #F56C6C;margin-left: 5px;">{{ state.n_ReviewnNoPassRecordCount }}</span></el-button>
                            <el-button  @click="stateClick(5,getData)" class="icon-e" text>验收不通过记录数量<span style="color: #c6ff40;margin-left: 5px;">{{ state.n_AcceptanceNoPassRecordCount }}</span></el-button> -->
                        </el-form-item>
                    </el-form>
                </el-card>
            </div>

            <div style="box-sizing: border-box;" class="flex-1 pos-r">
                <div class="pos-a w-h-100" style="box-sizing: border-box;">
                    <el-card class="box-card w-h-100" shadow="never" style="margin-top: 16px;">
                        <div style="" class="w-h-100 ver-flex">
                            <div class="flex-1 pos-r">
                                <div class="pos-a w-h-100">
                                    <el-table 
                                        ref="excelRef"
                                        :data="list" 
                                        class="w-h-100" 
                                        style="width: 100%" 
                                        border 
                                        v-loading="loading" 
                                        element-loading-background="rgba(0, 0, 0, 0.5)"
                                    >

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="巡检任务"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Task" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_IPTaskName">{{ scope.row.v_IPTaskName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患排查人员"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Check" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_CheckUserName">{{ scope.row.v_CheckUserName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患排查部门"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Dep" typeVal="cascader" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_CheckDeptName">{{ scope.row.v_CheckDeptName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="风险分析单元类型"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Type" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_TypeName">{{ scope.row.v_TypeName }}</span>
                                                    <span v-else>-</span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="风险管控分析单元"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Unit" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_AnalysisUnitName">{{ scope.row.v_AnalysisUnitName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="巡检点"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_SMSDCList" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_SMSDCListName">{{ scope.row.v_SMSDCListName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="是否自定义隐患"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Custom" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.isCustom">是</span>
                                                    <span v-else>否</span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column width="400" :show-overflow-tooltip="true" label="隐患排查日期"  align="center" prop="d_CheckDate" sortable>
                                            <el-table-column :show-overflow-tooltip="true" width="400" align="center">
                                                <template #header>
                                                    <SearchModel typeId="d_CheckDate" typeVal="daterange" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.d_CheckDate">{{ scope.row.d_CheckDate.split(' ')[0] }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患描述"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Describe" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Describe">{{ scope.row.v_Describe }}</span>
                                                    <span v-else>-</span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患级别"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Level" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_HiddenLevelName">{{ scope.row.v_HiddenLevelName }}</span>
                                                    <span v-else>-</span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患地点"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Place" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Place">{{ scope.row.v_Place }}</span>
                                                    <span v-else>-</span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患部位"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Part" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Part">{{ scope.row.v_Part }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <!-- <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患状态"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_State" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_StateName">{{ scope.row.v_StateName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column> -->

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="隐患分类"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Hidden" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_HiddenDangerClass">{{ scope.row.v_HiddenDangerClass }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="120" :show-overflow-tooltip="true" label="处理过程"  align="center" fixed="right">
                                            <template #default="scope">
                                                <el-button @click="resultHandle(scope.row)" class="icon-e" icon="ele-View" size="small" text type="primary">查看</el-button>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="180" :show-overflow-tooltip="true" prop="createdTime" label="创建时间"  align="center" sortable>
                                            <template #default="scope">
                                                <span v-if="scope.row.createdTime">{{ scope.row.createdTime }}</span>
                                                <span v-else>-</span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="180" :show-overflow-tooltip="true" prop="updatedTime" label="更新时间"  align="center" sortable>
                                            <template #default="scope">
                                                <span v-if="scope.row.updatedTime">{{ scope.row.updatedTime }}</span>
                                                <span v-else>-</span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column width="120" label="操作" align="center" fixed="right">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <el-button class="icon-e" @click='searchClick' icon="ele-Search" size="small" type="primary" text> 查询 </el-button>
                                                    <el-button class="icon-e clear-bg" style="background-color: transparent !important;" size="small" @click="resetClick" icon="ele-Refresh" text> 重置 </el-button>
                                                </template>
                                                <template #default="scope">
                                                    <el-button @click="detailHandle(scope.row.id)" class="icon-e" icon="ele-View" size="small" text type="success">详情</el-button>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                    </el-table>
                                </div>
                            </div>
                            <div style="height: 30px;margin-top: 20px;" class="hr-flex-start">
								<el-pagination
									v-model:currentPage="pageNo"
									v-model:page-size="pageSize"
									:total="totalRows"
									:page-sizes="[10, 20, 50, 100]"
									small
									background
									@size-change="handleSizeChange"
									@current-change="handleCurrentChange"
									layout="total, sizes, prev, pager, next, jumper"
									class="w-h-100"
								/>
							</div>
                        </div>
                    </el-card>
                </div>
            </div>
        </div>
        <!-- 详情 -->
        <DetailModel
            :detailInfo="detailInfo"
            :MdetailDialog="MdetailDialog"
            labelWidth="140px"
            @cancelDetailClick="cancelDetailClick"
        />
        <!-- 处理过程 -->
        <DisposeCourse
            statusVal="waitOne"
            :dispInfo="dispInfo"
            :dispDialog="dispDialog"
            @dispClick="dispClick"
        />
    </div>
</template>
<script lang="ts">
import { defineComponent, ref, Ref, onMounted , reactive , toRaw , toRefs } from 'vue';
import getTableData from '/@/utils/getTableData';
import { ElMessage } from 'element-plus';
import { 
    SMSIPTaskList,
    SMSHDHiddenDetail,
    SMSHDHiddenPage,
    SMSDCAnalysisUnitList,
    SMSDCListList,
    SMSHDHiddenListCount,
} from '/@/api/centerControl/sms';
import { sysOrgTree , sysUserselectorV2 , sysFileInfoPage } from '/@/api/centerControl/pubilc';
import SearchModel from '../component/search-model.vue';
import DetailModel from '../component/detail-model.vue';
import DisposeCourse from '../component/sms/dispose-course.vue';
import { exportToExcel } from '/@/utils/exportToExcel';

export default defineComponent( {
    name: 'have-filed',
    components: { SearchModel , DetailModel , DisposeCourse },
    setup(props){
        const isUseDialog = ref(false); // 新增/编辑弹出框隐藏/显示
        const repairInfo = ref(); // 传递子组件数据
        const isHoldDialog = ref(false);

        const state: any = reactive({
            n_FinishedRecordCount: 0
        });

        const dispInfo = ref();
        const dispDialog = ref(false);

        /*** getStateFun 获取状态信息 */
        const getStateFun = async() => {
            let param = {
                onlyMyRecord: true,
                n_State: 3,
            }
            let res: any = await SMSHDHiddenListCount(param);
            if(res.success) state.n_FinishedRecordCount = res.data;
        }

        /*** 获取数据字典值/部门数据 */
        const getDictFun = async() => {
            
        }

        /*** 登记整改结果取消事件 */
        const cancelUseClick = () => {
            isUseDialog.value = false;
        }

        /*** 登记整改结果提交事件 */
        const controlUseClick = () => {
            getStateFun();
            isUseDialog.value = false;
        }

        /*** 转办取消事件 */
        const cancelHoldClick = () => {
            isHoldDialog.value = false;
        }

        /*** 转办提交事件 */
        const controlHoldClick = () => {
            getStateFun();
            isHoldDialog.value = false;
        }

        /*** 隐患结果 */
        const resultHandle = (val: any) => {
            dispInfo.value = JSON.stringify(val);
            dispDialog.value = true;
        }

        /*** 处理过程取消事件 */
        const dispClick = () => {
            dispDialog.value = false;
        }

        /*** ================================= 详情类数据操作 =================================  */
        const MdetailDialog = ref(false);
        const detailInfo = ref();

        // 获取文件
        const getFileFun = async (sourceId: number) => {
            let param: any = {};
            param.PageNo = 1;
            param.PageSize = 99999;
            param.sourceId = sourceId;
            let res: any = await sysFileInfoPage(param);
            if(res.success) return res.data.rows;
        }
        /*** 获取详情接口数据 */
        const getDetailFun = async (id: number) => {
            let res: any = await SMSHDHiddenDetail({id: id}); // 详情
            if(res.success){
                console.log(res,'res');
                let setArr: any = [];
                let tableRectifyArr: any = [];
                let tableReviewArr: any = [];
                let tableAcceptanceArr: any = [];
                let detailObj: any = {};
                detailObj['巡检任务'] = res.data.v_IPTaskName;
                detailObj['隐患排查人员'] = res.data.v_CheckUserName;
                detailObj['隐患排查部门'] = res.data.v_CheckDeptName;
                detailObj['隐患分类'] = res.data.v_TypeName;
                detailObj['风险管控分析单元'] = res.data.v_AnalysisUnitName;
                detailObj['巡检点'] = res.data.v_SMSDCListName;
                detailObj['是否自定义隐患'] = res.data.isCustom ? '是' : '否';
                detailObj['隐患排查日期'] = res.data.d_CheckDate ? res.data.d_CheckDate.split(' ')[0] : '-';
                detailObj['隐患描述'] = res.data.v_Describe;
                detailObj['隐患等级'] = res.data.v_HiddenLevelName;
                detailObj['隐患地点'] = res.data.v_Place;
                detailObj['隐患部位'] = res.data.v_Part;
                detailObj['隐患状态'] = res.data.v_StateName;
                detailObj['隐患分类'] = res.data.v_HiddenDangerClass;

                if(res.data.smshdRectifyLast && Object.keys(res.data.smshdRectifyLast).length !== 0){
                    let hiddenInfo = res.data.smshdRectifyLast;
                    let detailObjHidden: any = {};
                    detailObjHidden['第几次整改'] = hiddenInfo.n_Times;
                    detailObjHidden['隐患整改类型'] = hiddenInfo.v_TypeName;
                    detailObjHidden['整改期限'] = hiddenInfo.d_LimitTime;
                    detailObjHidden['是否现场整改'] = hiddenInfo.isSceneRectify ? '是' : '否';
                    detailObjHidden['整改人员'] = hiddenInfo.v_RectifyUserName;
                    detailObjHidden['整改部门'] = hiddenInfo.v_RectifyDeptName;
                    detailObjHidden['整改措施'] = hiddenInfo.v_Measures;
                    detailObjHidden['整改状态'] = hiddenInfo.v_StateName;
                    detailObjHidden['是否整改转办'] = hiddenInfo.isRectificationShift ? '是' : '否';
                    detailObjHidden['整改结果状态'] = hiddenInfo.n_RectificationState === 0 ? '已消除' : '未消除';
                    detailObjHidden['整改时间'] = hiddenInfo.d_RectificationTime;
                    detailObjHidden['整改文字描述'] = hiddenInfo.v_RectificationDescribe;
                    detailObjHidden['原因分析'] = hiddenInfo.v_Reason;
                    detailObjHidden['复查部门'] = hiddenInfo.v_ReviewDeptName;
                    detailObjHidden['复查人员'] = hiddenInfo.v_ReviewUserName;
                    detailObjHidden['复查时间'] = hiddenInfo.d_ReviewTime;
                    detailObjHidden['复查是否转办'] = hiddenInfo.isReviewShift ? '是' : '否';
                    detailObjHidden['复查结果'] = hiddenInfo.v_ReviewResultName;
                    detailObjHidden['复查意见'] = hiddenInfo.v_ReviewOpinion;
                    detailObjHidden['验收部门'] = hiddenInfo.v_AcceptanceDeptName;
                    detailObjHidden['验收人员'] = hiddenInfo.v_AcceptanceUserName;
                    detailObjHidden['是否验收转办'] = hiddenInfo.isAcceptanceShift ? '是' : '否';
                    detailObjHidden['验收日期'] = hiddenInfo.d_AcceptanceTime;
                    detailObjHidden['验收结果'] = hiddenInfo.v_AcceptanceStateName;
                    setArr.push({
                        formTitle: '巡检任务基础信息',
                        type: 'form',
                        info: detailObjHidden,
                    });
                    if(hiddenInfo.l_RectifyFileId){
                        await getFileFun(hiddenInfo.l_RectifyFileId).then((item: any) => {
                            if(item.length !== 0){
                                item.map((val: any) => {
                                    let itemObj: any = {};
                                    itemObj['id'] = val.id;
                                    itemObj['fileObjectName'] = val.fileObjectName;
                                    itemObj['附件名称'] = val.fileOriginName;
                                    itemObj['文件格式'] = val.fileSuffix;
                                    itemObj['文件大小'] = val.fileSizeKb;
                                    itemObj['文件路径'] = val.filePath;
                                    tableRectifyArr.push(itemObj);
                                });
                            }
                        });
                    }
                    if(hiddenInfo.l_ReviewFileId){
                        await getFileFun(hiddenInfo.l_ReviewFileId).then((item: any) => {
                            if(item.length !== 0){
                                item.map((val: any) => {
                                    let itemObj: any = {};
                                    itemObj['id'] = val.id;
                                    itemObj['fileObjectName'] = val.fileObjectName;
                                    itemObj['附件名称'] = val.fileOriginName;
                                    itemObj['文件格式'] = val.fileSuffix;
                                    itemObj['文件大小'] = val.fileSizeKb;
                                    itemObj['文件路径'] = val.filePath;
                                    tableReviewArr.push(itemObj);
                                });
                            }
                        });
                    }
                    if(hiddenInfo.l_AcceptanceSignatureId){
                        await getFileFun(hiddenInfo.l_AcceptanceSignatureId).then((item: any) => {
                            if(item.length !== 0){
                                item.map((val: any) => {
                                    let itemObj: any = {};
                                    itemObj['id'] = val.id;
                                    itemObj['fileObjectName'] = val.fileObjectName;
                                    itemObj['附件名称'] = val.fileOriginName;
                                    itemObj['文件格式'] = val.fileSuffix;
                                    itemObj['文件大小'] = val.fileSizeKb;
                                    itemObj['文件路径'] = val.filePath;
                                    tableAcceptanceArr.push(itemObj);
                                });
                            }
                        });
                    }
                }
                setArr.push({
                    formTitle: '基础信息',
                    type: 'form',
                    info: detailObj,
                },{
                    tableTitle: '整改后照片',
                    type: 'table',
                    listData: tableRectifyArr,
                    minWidth: 160,
                    isShowBtn: true,
                },{
                    tableTitle: '复查照片',
                    type: 'table',
                    listData: tableReviewArr,
                    minWidth: 160,
                    isShowBtn: true,
                },{
                    tableTitle: '验收电子签名',
                    type: 'table',
                    listData: tableAcceptanceArr,
                    minWidth: 160,
                    isShowBtn: true,
                });
                detailInfo.value = setArr;
                MdetailDialog.value = true;
            }
        }
        /*** 详情 */
        const detailHandle = (id: number) => {
            getDetailFun(id);
        }
        /*** 详情关闭事件 */
        const cancelDetailClick = () => {
            MdetailDialog.value = false;
        }
        /*** ================================= 详情类数据操作 =================================  */
        
        /*** ================================= 查询类数据操作 =================================  */
        let searchObj:any = reactive({
            onlyMyRecord: true,
            n_State: 3,
        });
        const basicsInfo: any = ref([]);
        const searInfo: any = ref();

        /*** 获取需要查询的数据 */
        const searchHandel = (val: any) => {
            searInfo.value = val;
        }

        /*** 查询按钮 */
        const searchClick = () => {
            let newObj = Object.keys(searInfo.value);
            if(newObj.length !== 0){
                newObj.map((i:any) => {
                    searchObj[i] = searInfo.value[i];
                });
                searchObj.n_State = 3;
            }
        };

        /*** 重置按钮 */
        const resetClick = () => {
            searInfo.value = {};
            let newObj = Object.keys(searchObj);
            if(newObj.length !== 0){
                newObj.map((i:any) => {
                    searchObj[i] = ''
                });
            }
            searchObj.onlyMyRecord = true;
            searchObj.n_State = 3;
            getStateFun();
            initInfoFun();
        };

        let rectifyArr: any = [];
        let depArr: any = [];
        let taskArr: any = [];
        let unitArr: any = [];
        let SMSDCListArr: any = [];
        // 获取数据
        const getFun = async () => {
            let rbs: any = await sysUserselectorV2({}); // 用户
            let rcs: any = await sysOrgTree({}); // 部门
            let rds: any = await SMSIPTaskList({}); // 巡检任务
            let rfs: any = await SMSDCAnalysisUnitList({}); //风险分析单元列表
            let rjs: any = await SMSDCListList({}); // 巡检点
            if(rbs.success && rbs.data.length !== 0){
                rbs.data.map((item: any) => {
                    item.label = item.name;
                    item.value = item.id;
                });
                rectifyArr = rbs.data;
            }
            if(rcs.success && rcs.data.length !== 0) depArr = rcs.data;
            if(rds.success && rds.data.length !== 0){
                rds.data.map((item: any) => {
                    item.label = item.v_Name;
                    item.value = item.id;
                });
                taskArr = rds.data;
            }
            if(rfs.success && rfs.data.length !== 0){
                rfs.data.map((item: any) => {
                    item.label = item.v_RiskPartitionName ? item.v_RiskPartitionName + '——' + item.v_Name : item.v_Name;
                    item.value = item.id;
                });
                unitArr = rfs.data;
            }
            if(rjs.success && rjs.data.length !== 0){
                rjs.data.map((item: any) => {
                    item.label = item.v_CheckContent;
                    item.value = item.id;
                });
                SMSDCListArr = rjs.data;
            }
        }
        
        /*** 初始化数据 */
        const initInfoFun = () => {
            basicsInfo.value = [{
                    typeId: 's_Task', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_IPTaskId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '巡检任务', // placeholder数据
                    defaultProp: taskArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Check', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_CheckUserId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患排查人员', // placeholder数据
                    defaultProp: rectifyArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Dep', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_CheckDeptId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患排查部门', // placeholder数据
                    defaultProp: depArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                    propsVal: { checkStrictly: true , label: 'title', value: 'id', children: 'children' }, // 级联选择器 --- 选填
                },{
                    typeId: 's_Type', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'n_Type', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '风险分析单元类型', // placeholder数据
                    defaultProp: [
                        {label: '设备类', value: 0},
                        {label: '作业活动类', value: 1},
                    ], // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Unit', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_AnalysisUnitId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '风险管控分析单元', // placeholder数据
                    defaultProp: unitArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_SMSDCList', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_SMSDCListId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '巡检点', // placeholder数据
                    defaultProp: SMSDCListArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Custom', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'isCustom', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '是否自定义隐患', // placeholder数据
                    defaultProp: [
                        {label: '是', value: true},
                        {label: '否', value: false},
                    ], // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_Describe', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_Describe', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患描述', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'd_CheckDate', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchValMin: 'd_CheckDateMin', // 查询字段 --- 必填
                    searchValMax: 'd_CheckDateMax', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患排查日期', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Level', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'n_HiddenLevel', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患级别', // placeholder数据
                    defaultProp: [
                        {label: '重大隐患', value: 0},
                        {label: '较大隐患', value: 1},
                        {label: '严重隐患', value: 2},
                        {label: '一般隐患', value: 3},
                    ], // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_Place', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_Place', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患地点', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_Part', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'V_Part', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患部位', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_State', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'n_State', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患状态', // placeholder数据
                    defaultProp: [
                        {label: '待整改', value: 0},
                        {label: '待复查', value: 1},
                        {label: '待验收', value: 2},
                        {label: '已归档', value: 3},
                    ], // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'i_Hidden', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_HiddenDangerClass', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患分类', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'd_LimitTime', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchValMin: 'd_LimitTimeMin', // 查询字段 --- 必填
                    searchValMax: 'd_LimitTimeMax', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '整改期限', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_AcceptanceDept', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'n_AlarmState', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '隐患整改报警状态', // placeholder数据
                    defaultProp: [
                        {label: '预警', value: 0},
                        {label: '报警', value: 1},
                    ], // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                }
            ]
        }

        onMounted(async () => {
            await getStateFun();
            await getFun();
            await getDictFun();
            initInfoFun();
        });
        /*** ================================= 查询类数据操作 =================================  */

        /*** ================================= 导出数据函数操作 ================================= */
        const excelRef: any = ref(null);
        const handleExport = () => {
            if(excelRef.value){
                if(excelRef.value.data.length !== 0){
                    let tableExcel: any = [];
                    let tableArr = excelRef.value.data;
                    tableArr.map((item: any) => {
                        let tableObj: any = {};
                        tableObj['巡检任务'] = item.v_IPTaskName ? item.v_IPTaskName : '-';
                        tableObj['隐患排查人员'] = item.v_CheckUserName ? item.v_CheckUserName : '-';
                        tableObj['隐患排查部门'] = item.v_CheckDeptName ? item.v_CheckDeptName : '-';
                        tableObj['隐患分类'] = item.v_TypeName ? item.v_TypeName : '-';
                        tableObj['风险管控分析单元'] = item.v_AnalysisUnitName ? item.v_AnalysisUnitName : '-';
                        tableObj['巡检点'] = item.v_SMSDCListName ? item.v_SMSDCListName : '-';
                        tableObj['是否自定义隐患'] = item.isCustom ? '是' : '否';
                        tableObj['隐患排查日期'] = item.d_CheckDate ? item.d_CheckDate.split(' ')[0] : '-';
                        tableObj['隐患描述'] = item.v_Describe ? item.v_Describe : '-';
                        tableObj['隐患等级'] = item.v_HiddenLevelName ? item.v_HiddenLevelName : '-';
                        tableObj['隐患地点'] = item.v_Place ? item.v_Place : '-';
                        tableObj['隐患部位'] = item.v_Part ? item.v_Part : '-';
                        tableObj['隐患状态'] = item.v_StateName ? item.v_StateName : '-';
                        tableObj['隐患分类'] = item.v_HiddenDangerClass ? item.v_HiddenDangerClass : '-';
                        tableExcel.push(tableObj);
                    });
                    exportToExcel(tableExcel,'已归档隐患.xlsx');
                }else{
                    ElMessage({
                        type: 'error',
                        message: '暂无数据导出',
                    })
                }
            }
        }
        /*** ================================= 导出数据函数操作 ================================= */

        return {
            ...getTableData(SMSHDHiddenPage,{},searchObj),
            state,

            repairInfo,
            isUseDialog,
            cancelUseClick,
            controlUseClick,
            isHoldDialog,
            cancelHoldClick,
            controlHoldClick,

            // 导出Excel
            excelRef,
            handleExport,
            
            // 处理过程
            resultHandle,
            dispInfo,
            dispDialog,
            dispClick,
            
            // 详情
            MdetailDialog,
            detailHandle,
            detailInfo,
            cancelDetailClick,

            // 查询事件
            basicsInfo,
            searchHandel,
            searchClick,
            resetClick,
        }
    },
} )
</script>
<style lang="scss"> @import '../style/public.scss'; </style>
<style scoped lang="scss">
    ul {
        list-style: none;
        li {
            cursor: pointer;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            text-align: center;
            padding: 10px 0;
        }
    }
    .search-s{
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        width: 100%;
        .search-s-l{
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            width: 98%;
        }
    }
    #have-filed {
        .box-f{
            :deep(.el-form-item__label){
                padding: 0;
            }
        }
        :deep(.el-card__body) {
            height: 100%;
        }
        :deep(.el-card){
            border: none !important;
        }
        .upload-demo{
            margin-left: 12px;
            margin-top: 2px;
        }
        .icon-e{
            :deep(.el-icon){
                margin-right: 0px!important;
            }
        }
    }
.clear-bg{
    background-color: transparent !important;
}
</style>